package cn.itcast.demo.dao;

import cn.itcast.demo.pojo.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

//fallback 配置了这个接口中的方法的回调方法存在的类
@FeignClient(value = "user-service",fallback = UserClientFallback.class)
public interface UserClient {


    //feign帮我们来拼接请求地址

    // user-service -->http://localhost:8081/user/2  ----->json    ---->userObj

    //动态代理

    @GetMapping("user/{id}")
    @ResponseBody //直接复制目标controller的代码即可
    User queryUserById(@PathVariable("id") Long userId);
}
